package com.singfan.core.component;

import com.singfan.core.dao.database.model.CustomerToken;

/**
 * Author: hansonghe
 * Date: 2015-08-28 17:19
 * Desc:
 */
public class CustomerTokenHolder {
    private static final ThreadLocal<CustomerToken> customerTokenLocal = new ThreadLocal<CustomerToken>();

    public static void bindCustomerToken(CustomerToken customerToken){
        if(customerToken == null){
            customerTokenLocal.remove();
        }
        else{
            customerTokenLocal.set(customerToken);
        }
    }

    public static CustomerToken getCurrentCustomerToken(){
        return customerTokenLocal.get();
    }

    public static void unbindCustomerToken(){
        customerTokenLocal.remove();
    }
}
